class Admin::SubContractorsController < AdminController
  def index
    @sub_contractors = SubContractor.all
  end

  def new
    @sub_contractor = SubContractor.new
  end

  def create
    @sub_contractor = SubContractor.new(params[:sub_contractor])
    if @sub_contractor.save
      flash[:notice] = "Successfully created sub contractor."
      redirect_to admin_sub_contractors_url
    else
      render :action => 'new'
    end
  end

  def edit
    @sub_contractor = SubContractor.find(params[:id])
  end

  def update
    @sub_contractor = SubContractor.find(params[:id])
    if @sub_contractor.update_attributes(params[:sub_contractor])
      flash[:notice] = "Successfully updated sub contractor."
      redirect_to admin_sub_contractors_url
    else
      render :action => 'edit'
    end
  end

  def destroy
    @sub_contractor = SubContractor.find(params[:id])
    @sub_contractor.destroy
    flash[:notice] = "Successfully destroyed sub contractor."
    redirect_to admin_sub_contractors_url
  end
end
